home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / d86bios4.zip / ZBIOS1.8 < prev    next >
Text File  |  1989-07-07  |  35KB  |  960 lines

  1. ;------------------
  2. ;  WANG INTERFACE
  3. ;------------------
  4.  
  5. ; Thanks to Alan Tschetter for providing the information necessary for me
  6. ;   to program this interface.
  7.  
  8. WANG_KEYS:
  9.   DB 0E1           ; HELP key value
  10.   DB 07F-FUNC           ; add-quantity for FUNC
  11. L1:
  12.   DB 0C2,0C9,0C0,0C8,0C4 ; DOWN, NEXT, UP, PREV, HOME
  13.   DB 097,097           ; shift-F7 key, disabled Alt-F9 key
  14. N_CONTROL_KEYS EQU $-L1
  15.  
  16.   DW HELP_HELP      ; pointer to "HELP" message, the name of Wang's HELP key
  17.  
  18. L2:
  19.   DW WANG_COPY        ; VID_COPY routine
  20.   DW WANG_ATTR        ; VID_ATTR routine
  21.   DW RET        ; there is no VID_FIX necessary on the Wang
  22.   DW WANG_BELL        ; BIOS_BELL routine
  23.   DW WANG_KEY        ; BIOS_KEY routine
  24.   DW RET
  25.   DW RET
  26.   DW 0F000        ; new value for VIDEO_SEG
  27.   DB 0            ; normal-video attribute for the Wang PC
  28.   DB 2            ; reverse-video attribute for the Wang PC
  29. N_BIOS_CALLS EQU ($-L2)/2
  30.  
  31.  
  32. ; Other Wang keycodes:    F1--F16  80--8F
  33. ;            Prev     C8      Erase   CB
  34. ;            Insert     C6      Delete  C7
  35. ;            <---     C3      --->      C1
  36. ;            EXEC     C5
  37. ;   All the above codes add 010 for SHIFT versions.
  38. ;   NO ALT KEY!!!
  39. ;            Print     E3      Back Tab     CD
  40. ;            Cancel     E0      Shift Cancel 03
  41.  
  42.  
  43. ; WANG_CONFIG is the BIOS initialization routine for a Wang PC.  We copy the
  44. ;   values of WANG_KEYS to various locations, then we fetch the value of
  45. ;   ENABLE_PORT, that lets us access Wang's video memory, then we move the
  46. ;   user's cursor to the lower left corner.
  47.  
  48. L1:            ; console codes to move cursor to lower left corner
  49.   DB 01B,'[25;1H'       ; row 25, column 1
  50. L2 EQU $-L1        ; L2 is the count of bytes
  51.  
  52. WANG_CONFIG:
  53.   MOV SI,WANG_KEYS      ; point to Wang's table of key codes and other values
  54.   CALL NEW_KEYS         ; plug the new values into our program's data structures
  55.   MOV AL,1        ; function code for GET BIOS ENVIRONMENT
  56.   INT 088               ; sets ES to a segment where we'll find port #
  57.   ES MOV BX,[BX+10]    ; fetch a pointer
  58.   ES MOV AH,[BX+19]    ; use the pointer to fetch the high of the port #
  59.   MOV AL,010        ; low of the port # is always 010
  60.   MOV ENABLE_PORT,AX    ; store the port number
  61.   MOV DS,CS        ; point DS to our program, for console sequence
  62.   MOV DX,L1             ; point DX to the "go to lower left" console sequence
  63.   MOV CX,L2        ; load the number of bytes in the sequence
  64.   MOV BH,0              ; device number, maybe?  I don't know for sure
  65.   MOV AL,0D             ; function number, maybe?  I don't know for sure
  66.   INT 088               ; output escape string, user's cursor goes to lower left
  67.   RET
  68.  
  69.  
  70. ; WANG_COPY is the Wang-PC version of the VID_COPY routine.  The character
  71. ;   and attribute bytes are reversed from what they are on the IBM-PC, so
  72. ;   AH and AL are swapped before and after every word output.  There are no
  73. ;   snow problems; so we can get away with copying everything every time.
  74. ;   We do need to enable the video memory, though.
  75.  
  76. WANG_COPY:
  77.   MOV DX,ENABLE_PORT  ; fetch the port number for enabling video memory
  78.   MOV AL,1          ; value 1 causes memory to be enabled
  79.   OUT DX,AL          ; we can now access the video memory
  80. L1:              ; loop here for each character to be copied
  81.   LODSB           ; fetch the next character
  82.   XCHG AH,AL          ; swap character into AH, attribute byte into AL
  83.   STOSW           ; output the word to video memory
  84.   MOV AH,AL          ; copy the attribute byte back to AH, for next char
  85.   LOOP L1          ; loop to copy the next character
  86. L2:              ; common exit with WANG_ATTR
  87.   MOV AL,0          ; value 0 shuts off access to video memory
  88.   OUT DX,AL          ; video access is now disabled
  89.   RET
  90.  
  91.  
  92. ; WANG_ATTR is the Wang-PC version of the VID_ATTR routine.  The attribute
  93. ;    byte is the low byte of the DI-pointed video memory.  Also, to access it,
  94. ;    we must send the code that enables Wang video memory.
  95.  
  96. WANG_ATTR:
  97.   PUSH AX          ; preserve the attribute code
  98.   MOV DX,ENABLE_PORT  ; fetch the port number for enabling video memory
  99.   MOV AL,1          ; value 1 causes memory to be enabled
  100.   OUT DX,AL          ; we can now access the video memory
  101.   POP AX          ; restore the attribute code
  102.   STOSB           ; output the attribute byte to the LOW byte of video word
  103.   JMP L2          ; join common code to disable video access
  104.  
  105.  
  106. ; WANG_KEY is the Wang-PC version of the BIOS_KEY routine.
  107.  
  108. WANG_KEY:
  109.   PUSH BX          ; preserve register across call
  110. L1:              ; loop here to wait for a key to become ready
  111.   MOV AL,15          ; Wang BIOS function code for GET KEY STATUS
  112.   MOV BL,2            ; another parameter for Wang BIOS - I'm not sure which
  113.   INT 088          ; call Wang BIOS to get the status and maybe the key
  114.   TEST AL          ; do we have a key?
  115.   JNZ L1          ; loop if not, to try again
  116.   XCHG AX,BX          ; we do: swap the key code into AL for return
  117.   POP BX          ; restore clobbered register
  118.   RET
  119.  
  120.  
  121. ; WANG_BELL is the Wang-PC version of the BIOS_BELL routine.
  122.  
  123. WANG_BELL:
  124.   MOV BX,7          ; BL=7 is the BELL code; the BIOS also wants BH=0
  125.   MOV AL,6          ; Wang BIOS function code for CONSOLE OUTPUT
  126.   INT 088          ; output the BELL control code to the Wang console
  127.   RET
  128.  
  129.  
  130. ;------------------
  131. ;  TI-PC INTERFACE
  132. ;------------------
  133.  
  134. ; Thanks to David R. Cook for writing the following code.  I have reformatted
  135. ; it to look like the rest of my code, and made optimizations.
  136.  
  137. TIPC_KEYS:
  138.   DB 0B5       ; key code for F11 - the help key
  139.   DB 0AA-FUNC       ; F1 is code 0AB on the TI-PC
  140. L1:
  141.   DB 0C0       ; down-arrow key
  142.   DB 0C1       ; no PgDn key on the TI-PC, so we use alt-down-arrow code
  143.   DB 0B8       ; up-arrow key
  144.   DB 0B9       ; no PgUp key on the TI-PC, so we use alt-up-arrow code
  145.   DB 0B7       ; HOME key
  146.   DB 0CA       ; shift-F7 key
  147.   DB 0E0       ; alt-F9 key
  148. N_CONTROL_KEYS equ $-L1
  149.  
  150.   DW F11_HELP       ; pointer to help message
  151.  
  152. L2:
  153.   DW TIPC_COPY        ; VID_COPY routine
  154.   DW TIPC_ATTR        ; VID_ATTR routine
  155.   DW TIPC_FIX        ; VID_FIX routine
  156.   DW TIPC_BELL        ; BIOS_BELL routine
  157.   DW TIPC_KEY        ; BIOS_KEY routine
  158.   DW RET
  159.   DW RET
  160.   DW 0DE00        ; new value for VIDEO_SEG
  161.   DB 0F         ; normal-video attribute for the TI-PC
  162.   DB 01F        ; reverse-video attribute for the TI-PC
  163. N_BIOS_CALLS equ ($-L2)/2
  164.  
  165. ; Other TI keycodes:
  166.  
  167. ;   key   +shift  +alt      +ctrl  plain
  168. ;   ----------------------------------
  169. ;   F1      0C4      0D8      0CE     0AB
  170. ;   ...
  171. ;   F10   0CD      0E1      0D7     0B4
  172. ;   F11   "x"     "|"     "z"    0B5
  173. ;   F12   "y"     "}"     "{"    0B6
  174. ;
  175. ;   PRNT             0E2
  176. ;   INS   098      09A      099     0C2
  177. ;   DEL   0A8      0AA      0A9     0C3
  178. ;   UP AR 0F8      0B9      0F4
  179. ;   DN AR 0F9      0C1      0E6
  180. ;   LT AR 0FB      0BC      0E3     0BB
  181. ;   RT AR 0FA      0BE      0E4     0BD
  182. ;   HOME  0F6      0F5      0E7
  183. ;   TAB   07F    ignored ignored   09
  184.  
  185.  
  186.  
  187. ; TIPC_CONFIG is the BIOS initialization routine for the TI-PC.  We copy the
  188. ;   values in TIPC_KEYS to various locations, then we drop into TIPC_FIX,
  189. ;   to reset the cursor.
  190.  
  191. TIPC_CONFIG:
  192.   MOV SI,TIPC_KEYS      ; point to configuration-table for TI-PC's BIOS
  193.   CALL NEW_KEYS     ; copy the values to our tables
  194. TIPC_FIX:
  195.   MOV AH,014            ; BIOS function code for "clear graphics screen"
  196.   INT 049        ; clear the graphics screen
  197.   MOV AH,013            ; BIOS function code for "clear text screen"
  198.   INT 049        ; clear the text screen
  199.   MOV AH,2              ; BIOS function code for "position the cursor"
  200.   MOV DX,1 BY 24    ; first column, 24th row
  201.   INT 049               ; move the user's cursor to the bottom left corner
  202.   RET
  203.  
  204.  
  205. ; TIPC_COPY is the VID_COPY routine for the TIPC video board.  The attribute
  206. ;   AH is written to a single memory-mapped latch in the video segment.
  207. ;   Then the text bytes can be copied as-is.
  208.  
  209. TIPC_COPY:
  210.   ES MOV B[01801],AH    ; set the attribute latch
  211.   SHR DI,1        ; adjust the video address for bytes, not words
  212.   REP MOVSB        ; copy the text as-is
  213.   SHL DI,1        ; restore the video address to words, not bytes
  214.   RET
  215.  
  216.  
  217. ; TIPC_ATTR is the VID_ATTR routine for TI-PC computer.  We change the
  218. ;   attribute latch to the one provided in AL, then we add 0 to the video
  219. ;   character in memory, causing the new latch value to take effect.
  220.  
  221. TIPC_ATTR:
  222.   SHR DI,1        ; adjust video address for bytes, not words
  223.   E